package com.learning.security.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.learning.security.dal.dataobject.MenuDO;
import com.learning.security.dal.mysql.MenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author xxx
 * @since 2024-09-20
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuDO> implements MenuService {
    @Autowired
    private MenuRoleService menuRoleService;

    @Override
    public List<MenuDO> getAllMenu() {
        List<MenuDO> menuDOList = this.list();
        for (MenuDO menuDO : menuDOList) {
            menuDO.setRoles(menuRoleService.listRolesByMenuId(menuDO.getId()));
        }
        return menuDOList;
    }
}
